<template>
	<view class="container">
		<!-- 关键信息点 -->
		<view class="info-item" style="margin-top: 19%;">线索已收到，将在5个工作日内回复。</view>
		<!-- 二维码区域 -->
		<view class="qrcode-container">
			<canvas canvas-id="qrcode" style="width:270px; height:270px; margin-left: 28px;"></canvas>
		</view>
		<view class="info-item" style="margin-top: 7%;">二维码扫码直接查询</view>

	</view>
</template>

<script>
	import { baseUrl, baseApi } from '@/config';
	import uQRCode from '@/api/ewm/uqrcode.js'; //引入uqrcode.js
	export default {
		data() {
			return {
				qrCodeUrl:'http:www.baidu.com',
				category:'',
				leixing:'',
				id: '',
				second: 0,
				minute: 2,
				qrShow: false,
				show: true,
				loginForm: {
					username: "",
					password: "",
					// captchaVerification: "",
					openId: ""
				},
			};
		},
		// Vue实例的数据和方法
		onLoad(options) {
			//将openid存到投诉表的userId字段
			const app = getApp();
			this.loginForm.openId = app.globalData.openId;
			this.leixing = options.leixing;
			this.category = options.category;
			this.id = options.id
			if(options.category== "smjb"){
					// url: '
				this.qrFun(baseUrl+'/pages/work/xiangqing/smjb?id='+options.id+'&category='+this.leixing+'&openId='+this.loginForm.openId );
			}else if(options.category== "nmjb"){
				this.qrFun(baseUrl+'/pages/work/xiangqing/nmjb?id='+options.id+'&category='+this.leixing+'&openId='+this.loginForm.openId );
			}
			if(this.loginForm.openId){
				this.loginForm.username = 'admin';
				this.loginForm.password = 'admin123';
				this.$store.dispatch('Login', this.loginForm).then(() => {
					console.log('用户已登录');
				}).catch(error => {
				  // 登录失败的处理
				  console.error('登录失败', error);
				  this.$store.dispatch('GetInfo', this.pid).then(res => {
				  	this.$tab.reLaunch('/pages/login')
				  })
				});
				
			}else{
				this.$store.dispatch('GetInfo', this.pid).then(res => {
					this.$tab.reLaunch('/pages/login')
				})
			}
		},
		 methods: {  
		  //**生成二维码**//
		  	qrFun(text) {
				
		  		uQRCode.make({ 
		  			canvasId: 'qrcode',
		  			componentInstance: this,
		  			text: this.qrCodeUrl, //这里的text需要生成的二维码地址
		  			size: 270, //和上面保持一致即可默认像素
		  			margin: 0,
		  			backgroundColor: '#ffffff',
		  			foregroundColor: '#000000',
		  			fileType: 'jpg',
		  			errorCorrectLevel: uQRCode.errorCorrectLevel.H,
		  			success: res => {
						// if(category== "smjb"){
						// 		// url: '
						// 	uni.navigateTo({url : baseUrl+'/pages/work/xiangqing/smjb?id='+this.id+'&category='+this.leixing})
						// }else if(category== "nmjb"){
						// 	uni.navigateTo({url :baseUrl+'/pages/work/xiangqing/nmjb?id='+this.id+'&category='+this.leixing})
						// 	//this.$tab.reLaunch();
						// }
					}
		  		})
		  	}
		}  
	};
</script>

<style scoped>
	.container {
		padding: 20px;
		font-family: -apple-system-font, "Helvetica Neue", sans-serif;
	}

	.title {
		font-size: 24px;
		font-weight: bold;
		color: #333;
		margin-bottom: 10px;
	}

	.subtitle {
		font-size: 18px;
		color: #666;
		margin-bottom: 20px;
	}

	.info-item {
		font-size: 16px;
		color: #333;
		margin-bottom: 3%;


		text-align: center;
		font-weight: bold;
	}

	.qrcode-container {
		margin-top: 20px;
		text-align: center;
	}

	.qrcode {
		/* width: 150px;
		height: 150px; */
	}
</style>